
//
//  MyStockTVC.m
//  RedManStock
//
//  Created by lanou3g on 15/8/8.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "MyStockTVC.h"
#import "DataHandle.h"
#import "MyStockTableViewCell.h"
@interface MyStockTVC ()

@property(nonatomic,strong)NSMutableArray *myStockArray;

@end

@implementation MyStockTVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.myStockArray = [NSMutableArray array];
    
    NSMutableArray *array = [NSMutableArray array];
    array = [DataHandle shareHandle].allStockArray;
    for (SimpleStock *stock in array) {
        
        if (stock.collect == YES) {
            
            [self.myStockArray addObject:stock];
        }
        
    }
 
    
    [self.tableView registerNib:[UINib nibWithNibName:@"MyStockTableViewCell" bundle:nil] forCellReuseIdentifier:@"mystock"];
    
    

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - 分行 -
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.myStockArray.count;
}
#pragma mark - 分区 -
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
#pragma mark - cell复用 -
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    MyStockTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mystock" forIndexPath:indexPath];
    SimpleStock *stock = [[SimpleStock alloc]init];
    stock = [self.myStockArray objectAtIndex:indexPath.row];
    cell.nameLabel.text = stock.name;
    cell.codeLabel.text = stock.code;
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
